//
//  AllCountViewController.m
//  Qyer
//
//  Created by 赵宇 on 15/9/15.
//  Copyright (c) 2015年 赵宇. All rights reserved.
//

#import "AllCountViewController.h"
#import "BaseHeader.h"
@interface AllCountViewController ()<UIScrollViewDelegate,UITableViewDataSource,UITableViewDelegate,UICollectionViewDataSource,UICollectionViewDelegate>


@end

@implementation AllCountViewController
-(void)dealloc
{
    [_navView release];
    [_urlStr release];
    [_picArr release];
    [_inforr release];
    [_hotMguideArr release];
    [_localDiscountArr release];
    [_newdiscountArr release];
    [_titleScroll release];
    [_myDataDic release];
    [_bigScroll release];
    [_firstView release];
    [_secondView release];
    [_freeTable release];
    [_navCnname release];
    [_navEnname release];
    [_collectArr release];
    [super dealloc];
}
-(void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBarHidden = YES;
    self.tabBarController.tabBar.hidden = YES;
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBarHidden = YES;
    self.automaticallyAdjustsScrollViewInsets = NO;
    _pageCount = 1;

    [self getTheData];
}
-(void)getTheData
{
    self.collectArr = [[NSMutableArray alloc]init];
    _inforr = [[NSMutableArray alloc]init];
    _picArr = [[NSMutableArray alloc]init];
    _hotMguideArr = [[NSMutableArray alloc]init];
    _newdiscountArr = [[NSMutableArray alloc]init];
    _localDiscountArr = [[NSMutableArray alloc]init];
    NSString *string =[NSString stringWithFormat:@"http://open.qyer.com/qyer/footprint/city_detail?city_id=%@&client_id=qyer_ios&client_secret=cd254439208ab658ddf9&count=20&oauth_token=d5ecb9febb61510d54ba2d47d986cf65&page=1&track_app_version=6.6.6&track_deviceid=301FBCE0-A789-4EAC-ADF1-95E1AACF2A70", self.urlStr];
    [AFNblock getdataWithUrlString:string dataBlock:^(id block) {
        [self deallDataWithDic:block];
        
    } netBlock:^(id block) {
        [self deallDataWithDic:block];
        
    }];
}
-(void)deallDataWithDic:(NSDictionary *)block
{
    NSDictionary *bigDic = block;
    NSDictionary *dataDic = [bigDic objectForKey:@"data"];
    _myDataDic = [[NSDictionary alloc]initWithDictionary:dataDic];
    
    hot_countryModel *citymodel = [[hot_countryModel alloc]initWithDictionary:dataDic];
    [_inforr addObject:citymodel];
    
    NSArray *photoArr = [dataDic objectForKey:@"photos"];
    
    citymodel.pic = [photoArr firstObject];
    for (int i = 0; i < photoArr.count; i++) {
        NSString *url = [photoArr objectAtIndex:i];
        [_picArr addObject:url];
    }
    
    NSArray *hotmguideArr = [dataDic objectForKey:@"hot_mguide"];
    for (int i = 0; i < hotmguideArr.count; i++) {
        NSDictionary *dic = [hotmguideArr objectAtIndex:i];
        HotMguideModel *guide = [[HotMguideModel alloc]initWithDictionary:dic];
        [_hotMguideArr addObject:guide];
    }
    NSArray *localdiscount = [dataDic objectForKey:@"local_discount"];
    for (int i = 0; i < localdiscount.count; i++) {
        NSDictionary *dic = [localdiscount objectAtIndex:i];
        LocalModel *local = [[LocalModel alloc]initWithDictionary:dic];
        [_localDiscountArr addObject:local];
    }
    NSArray *newdiscount = [dataDic objectForKey:@"new_discount"];
    for (int i = 0; i < newdiscount.count; i++) {
        NSDictionary *discountdic = [newdiscount objectAtIndex:i];
        freeModel *discountMod = [[freeModel alloc]initWithDictionary:discountdic];
        [_newdiscountArr addObject:discountMod];
    }
    
    [self creatBigScroll];
    [self creatNavigation];

}
-(void)creatNavigation
{
    _navView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 64)];
    _navView.backgroundColor = [UIColor whiteColor];
    
    UILabel *cnnameLab = [[UILabel alloc]initWithFrame:CGRectMake(0, 20, SCREEN_WIDTH, 30)];
    cnnameLab.textAlignment = YES;
    cnnameLab.textColor = [UIColor blackColor];
    cnnameLab.text = self.navCnname;
    [_navView addSubview:cnnameLab];
    
    UILabel *ennameLab = [[UILabel alloc]initWithFrame:CGRectMake(0, 40, SCREEN_WIDTH, 24)];
    ennameLab.text = self.navEnname;
    ennameLab.textAlignment = YES;
    ennameLab.textColor = [UIColor grayColor];
    [_navView addSubview:ennameLab];
    
    
    UIButton *whiteBut = [UIButton buttonWithType:UIButtonTypeCustom];
    whiteBut.frame = CGRectMake(10, 20, 30, 30);
    [whiteBut addTarget:self action:@selector(backbeforeView) forControlEvents:UIControlEventTouchUpInside];
    [whiteBut setImage:[UIImage imageNamed:@"whiteback"] forState:UIControlStateNormal];
    [self.view addSubview:whiteBut];
    
    UIButton *wGift = [UIButton buttonWithType:UIButtonTypeCustom];
    wGift.frame = CGRectMake(SCREEN_WIDTH - 40, 20, 30, 30);
    [wGift setImage:[UIImage imageNamed:@"whitegift"] forState:UIControlStateNormal];
    [wGift addTarget:self action:@selector(smallStrategy:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:wGift];
    
    UIButton *gobackBut = [UIButton buttonWithType:UIButtonTypeCustom];
    gobackBut.frame = CGRectMake(10, 20, 30, 30);
    [gobackBut setImage:[UIImage imageNamed:@"iconfont-31fanhui1"] forState:UIControlStateNormal];
    [gobackBut addTarget:self action:@selector(backbeforeView) forControlEvents:UIControlEventTouchUpInside];
    [_navView addSubview:gobackBut];

    UIButton *gift = [UIButton buttonWithType:UIButtonTypeCustom];
    gift.frame = CGRectMake(SCREEN_WIDTH - 40, 20, 30, 30);
    [gift setImage:[UIImage imageNamed:@"gift"] forState:UIControlStateNormal];
    [gift addTarget:self action:@selector(smallStrategy:) forControlEvents:UIControlEventTouchUpInside];
    [_navView addSubview:gift];
    
    [self.view addSubview:_navView];
    _navView.alpha = 0;
    
    [_navView release];
    [cnnameLab release];
    [ennameLab release];
}
-(void)backbeforeView
{
    [self.navigationController popViewControllerAnimated:YES];
}

-(void)creatBigScroll
{
    [self creatTitleScroll];
    [self creatFirstViewAndSecondView];
    _bigScroll = [[UIScrollView alloc]initWithFrame:self.view.frame];
    [_bigScroll setContentSize:CGSizeMake(0, _titleScroll.frame.size.height + _firstView.frame.size.height + _secondView.frame.size.height)];
    _bigScroll.backgroundColor = [UIColor whiteColor];
    [_bigScroll setDelegate:self];
    [_bigScroll addSubview:_titleScroll];
    [_bigScroll addSubview:_firstView];
    [_bigScroll addSubview:_secondView];
    
    UIImageView *backView = [[UIImageView alloc]initWithFrame:CGRectMake(0, _titleScroll.frame.size.height/2, SCREEN_WIDTH, _titleScroll.frame.size.height/2)];
    backView.userInteractionEnabled = YES;
    [backView setImage:[UIImage imageNamed:@"backViewCell"]];
    [_bigScroll addSubview:backView];
    
    hot_countryModel *model = [_inforr objectAtIndex:0];
    UILabel *cnnameLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, SCREEN_HEIGHT/5*2-120, 180, 30)];
    self.navCnname = model.cnname;
    cnnameLabel.text = self.navCnname;
    cnnameLabel.font = [UIFont boldSystemFontOfSize:18.];
    cnnameLabel.textColor = [UIColor whiteColor];
    [_bigScroll addSubview:cnnameLabel];
// 收藏按钮
    UIButton *collect = [UIButton buttonWithType:UIButtonTypeCustom];
    collect.frame = CGRectMake(SCREEN_WIDTH*0.88, SCREEN_HEIGHT/5*2-90, 0.1*SCREEN_WIDTH, 0.1*SCREEN_WIDTH);
    [collect setImage:[UIImage imageNamed:@"dislike"] forState:UIControlStateNormal];
    [collect setImage:[UIImage imageNamed:@"like"] forState:UIControlStateSelected];
    [collect addTarget:self action:@selector(collectButton:) forControlEvents:UIControlEventTouchUpInside];
    [_bigScroll addSubview:collect];
// 先把全部的按钮置为没选中,然后查询数据库的全部数据,如果数据库里有和本页对应的城市名字相同的,则把它的收藏按钮设为选中❤️
    collect.selected = NO;
    NSArray *arr = [[DataBase shareDataBase]selectALL];
    for (MyCollectModel *M in arr) {
        if ([[_myDataDic objectForKey:@"cnname"] isEqualToString:M.cnname]) {
            collect.selected = YES;
        }
    }

    UILabel *ennameLabel = [[UILabel alloc]initWithFrame:CGRectMake(20,SCREEN_HEIGHT/5*2-90, 300, 30)];
    self.navEnname = model.enname;
    ennameLabel.text = self.navEnname;
    ennameLabel.font = [UIFont systemFontOfSize:14.];
    ennameLabel.textColor = [UIColor whiteColor];
    [_bigScroll addSubview:ennameLabel];
    
    UILabel *entryContLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, SCREEN_HEIGHT/5*2-60, SCREEN_WIDTH - 40, 60)];
    entryContLabel.text = model.entryCont;
    entryContLabel.numberOfLines = 2;
    entryContLabel.font = [UIFont systemFontOfSize:14.];
    entryContLabel.textColor = [UIColor whiteColor];
    [_bigScroll addSubview:entryContLabel];
// 如果这个城市过于冷门,既没有当地游也没有自由行,则放一张图提示用户没有这两个
    if(_localDiscountArr.count == 0 && _newdiscountArr.count == 0){
        UIImageView *noView = [[UIImageView alloc]initWithFrame:CGRectMake(0, SCREEN_HEIGHT/5*2, SCREEN_WIDTH, SCREEN_HEIGHT/5*3)];
        [noView setImage:[UIImage imageNamed:@"no.png"]];
        
        [_bigScroll addSubview:noView];
        [noView release];
    }

    [self.view addSubview:_bigScroll];
    
    [_bigScroll release];
    [backView release];
    [cnnameLabel release];
    [ennameLabel release];
    [entryContLabel release];
}
-(void)collectButton:(UIButton *)sender
{
    NSArray *arr = [[DataBase shareDataBase]selectALL];
    MyCollectModel *m = [[MyCollectModel alloc]initWithDictionary:_myDataDic];
    m.cid = [_myDataDic objectForKey:@"id"];
// 把轮播图的第一张照片存入数据库
    NSArray *photoArr = [_myDataDic objectForKey:@"photos"];
    m.pic = [photoArr firstObject];
    if (arr.count == 0) {
        [[DataBase shareDataBase]insertAct:m];
    }else{
        int count = 0;
        for (MyCollectModel *mod in arr)
        {
            if (![mod.cnname isEqualToString:m.cnname]) {
                count++;
            }
        }
//count == arr.count说明想要存入的数据和数据库里面的每个model都不一样,所以把它存入数据库
        if (count == arr.count) {
            [[DataBase shareDataBase]insertAct:m];
        }
    }
    
    if (sender.selected == NO) {
        
        sender.selected = YES;
    }else{
        sender.selected = NO;
        [[DataBase shareDataBase]deleteWithCnname:m.cnname];
    }
}
-(void)creatTitleScroll
{
    _titleScroll = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT/5*2)];
    
    [_titleScroll setContentOffset:CGPointMake(SCREEN_WIDTH, 0)];
    [_titleScroll setPagingEnabled:YES];
    [_titleScroll setDelegate:self];
    [_titleScroll showsHorizontalScrollIndicator];
    
    if (_picArr.count > 1)
    {
        for (int i = 0; i < _picArr.count+2; i++)
        {
            [_titleScroll setContentSize:CGSizeMake((_picArr.count+2)*SCREEN_WIDTH, 0)];
            UIImageView *pic = [[UIImageView alloc]initWithFrame:CGRectMake(i*SCREEN_WIDTH, 0, SCREEN_WIDTH, SCREEN_HEIGHT/5*2)];
            pic.userInteractionEnabled = YES;
        
            if (i == 0) {
                [pic sd_setImageWithURL:[NSURL URLWithString:[_picArr objectAtIndex:_picArr.count-1]] placeholderImage:[UIImage imageNamed:@"zhanweiPic"]];
            }
            if (i>0&&i<_picArr.count+1)
            {
                [pic sd_setImageWithURL:[NSURL URLWithString:[_picArr objectAtIndex:i-1]] placeholderImage:[UIImage imageNamed:@"zhanweiPic"]];
                
                
            }if (i == _picArr.count +1)
            {
                [pic sd_setImageWithURL:[NSURL URLWithString:[_picArr objectAtIndex:0]] placeholderImage:[UIImage imageNamed:@"zhanweiPic"]];
            }
            [_titleScroll addSubview:pic];
        }
    
        NSTimer *cityTime = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(titleScrollTimer) userInfo:nil repeats:YES];
    }
    if (_picArr.count == 1) {
        UIImageView *pic = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH, 0, SCREEN_WIDTH, SCREEN_HEIGHT/5*2)];
        
        [pic sd_setImageWithURL:[NSURL URLWithString:[_picArr objectAtIndex:0]] placeholderImage:[UIImage imageNamed:@"zhanweiPic"]];
        
        [_titleScroll addSubview:pic];
    }
    else{
        UIImageView *pic = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH, 0, SCREEN_WIDTH, SCREEN_HEIGHT/5*2)];
        [_titleScroll addSubview:pic];
    }
}

-(void)titleScrollTimer
{
    _pageCount++;
    [_titleScroll setContentOffset:CGPointMake(_pageCount * SCREEN_WIDTH, 0) animated:YES];
}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if (scrollView == _titleScroll)
    {
        // 偏移量/当页宽度 = 当前第几页
        _pageCount = _titleScroll.contentOffset.x / SCREEN_WIDTH;
    
        if (_pageCount == _picArr.count +1) {
            [_titleScroll setContentOffset:CGPointMake(SCREEN_WIDTH, 0) animated:NO];
        _pageCount = 1;
    }
        if (_titleScroll.contentOffset.x <= 0)
        {
            [_titleScroll setContentOffset:CGPointMake(_picArr.count * SCREEN_WIDTH, 0) animated:NO];
        }
    }
    if (scrollView == _bigScroll) {
        
    _navView.alpha = 0.01*scrollView.contentOffset.y;
        if (scrollView.contentOffset.y < 0)
        {
            _titleScroll.transform = CGAffineTransformMakeScale((_titleScroll.frame.size.height - _bigScroll.contentOffset.y)/_titleScroll.frame.size.height, (_titleScroll.frame.size.height - _bigScroll.contentOffset.y)/_titleScroll.frame.size.height);
            _titleScroll.center = CGPointMake(SCREEN_WIDTH/2, _titleScroll.frame.size.height/2+_bigScroll.contentOffset.y);
            
        }
        
    }
}
-(void)smallStrategy:(UIButton *)sender
{
    SmallStrategyViewController *small = [[SmallStrategyViewController alloc]init];
    hot_countryModel *mod = [_inforr objectAtIndex:0];
    small.url = mod.cid;
    [self.navigationController pushViewController:small animated:YES];
       
}
#pragma mark - 💚创建2个View,View1 = label(精彩当地游 查看全部) + CollectionView(4个item,来自local_discount),View2 = label(超值自由行 查看全部) + Tableview(n个cell),然后把View1和View2和轮播图放在一个大的Scroll上面
-(void)creatFirstViewAndSecondView
{
    _firstView = [[UIView alloc]initWithFrame:CGRectZero];
    _secondView =[[UIView alloc]initWithFrame:CGRectZero];
    if (_localDiscountArr.count != 0)
    {
        if (_localDiscountArr.count % 2 == 0) {
            _number = (int)_localDiscountArr.count/2;
        }else{
            _number = (int)_localDiscountArr.count/2+1;
        }

        _firstView.frame =CGRectMake(0, SCREEN_HEIGHT/5*2, SCREEN_WIDTH, _number*(SCREEN_HEIGHT/5*2+SCREEN_WIDTH/25)+0.1*SCREEN_HEIGHT);
        UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH/3, 0.1*SCREEN_WIDTH)];
        title.text = @"精彩当地游";
        title.font = [UIFont systemFontOfSize:15.];
        title.textColor = [UIColor grayColor];
        [_firstView addSubview:title];
        
        UIButton *firstBut = [UIButton buttonWithType:UIButtonTypeCustom];
        firstBut.frame = CGRectMake(SCREEN_WIDTH/3*2, 0, SCREEN_WIDTH/3,0.1*SCREEN_WIDTH);
        [firstBut setTitle:@"查看全部>" forState:UIControlStateNormal];
        firstBut.titleLabel.font = [UIFont systemFontOfSize:15.];
        [firstBut addTarget:self action:@selector(pushLacal) forControlEvents:UIControlEventTouchUpInside];
        [firstBut setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [_firstView addSubview:firstBut];
        
        UIView *line1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0.1*SCREEN_WIDTH, SCREEN_WIDTH, .6)];
        line1.backgroundColor = [UIColor grayColor];
        [_firstView addSubview:line1];
        
        UICollectionViewFlowLayout *flow = [[UICollectionViewFlowLayout alloc]init];
        flow.itemSize = CGSizeMake(SCREEN_WIDTH/7*3.1, SCREEN_HEIGHT/5*2);
        
        flow.sectionInset = UIEdgeInsetsMake(SCREEN_WIDTH/35, SCREEN_WIDTH/25, SCREEN_WIDTH/35, SCREEN_WIDTH/25);
        UICollectionView *firstCollection = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0.065*SCREEN_HEIGHT, SCREEN_WIDTH, _number*(SCREEN_HEIGHT/5*2+SCREEN_WIDTH/25)+0.05*SCREEN_HEIGHT) collectionViewLayout:flow];
        [firstCollection registerClass:[LocalCollectionViewCell class] forCellWithReuseIdentifier:@"firstCollectionCell"];
        firstCollection.backgroundColor = [UIColor whiteColor];
        [firstCollection setDelegate:self];
        [firstCollection setDataSource:self];
         [_firstView addSubview:firstCollection];
    }
    if ( _newdiscountArr.count != 0 ) {
        
        _freeTable = [[UITableView alloc]initWithFrame:CGRectMake(0, 0.1*SCREEN_WIDTH, SCREEN_WIDTH, _newdiscountArr.count*(SCREEN_HEIGHT/ 6 + 10)) style:UITableViewStylePlain];
        [_freeTable setDelegate:self];
        [_freeTable setDataSource:self];
        
        _secondView.frame = CGRectMake(0, _firstView.frame.size.height+_titleScroll.frame.size.height, SCREEN_WIDTH, _freeTable.frame.size.height+0.1*SCREEN_WIDTH);
         [_secondView addSubview:_freeTable];
        
        UIView *line2 = [[UIView alloc]initWithFrame:CGRectMake(0, .1, SCREEN_WIDTH,.6)];
        line2.backgroundColor = [UIColor grayColor];
        [_secondView addSubview:line2];
        
        UILabel *title = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH/3, 0.1*SCREEN_WIDTH)];
        title.font = [UIFont systemFontOfSize:15.];
        title.text = @"超值自由行";
        title.textColor = [UIColor grayColor];
        [_secondView addSubview:title];
        
        UIButton *secBut = [UIButton buttonWithType:UIButtonTypeCustom];
        secBut.frame = CGRectMake(SCREEN_WIDTH/3*2, 0, SCREEN_WIDTH/3, 0.1*SCREEN_WIDTH);
        [secBut setTitle:@"查看全部>" forState:UIControlStateNormal];
        secBut.titleLabel.font = [UIFont systemFontOfSize:15.];
        [secBut addTarget:self action:@selector(pushFreeTravel) forControlEvents:UIControlEventTouchUpInside];
        [secBut setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [_secondView addSubview:secBut];
        
        UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, 0.1*SCREEN_WIDTH, SCREEN_WIDTH, .6)];
        line.backgroundColor = [UIColor grayColor];
        [_secondView addSubview:line];

       
    }
    
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)sectio
{
    return _localDiscountArr.count;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    LocalCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"firstCollectionCell" forIndexPath:indexPath];
    LocalModel *loc = [_localDiscountArr objectAtIndex:indexPath.row];
    [cell setValueWithModel:loc];
    return cell;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    SlideViewController *web = [[SlideViewController alloc]init];
    LocalModel *loca = [_localDiscountArr objectAtIndex:indexPath.row];
    NSString *str = [NSString stringWithFormat:@"http://m.qyer.com/z/deal/%@/?source=app&client_id=qyer_ios&track_app_version=6.6.6&track_deviceid=301FBCE0-A789-4EAC-ADF1-95E1AACF2A70&track_user_id=6695170",loca.cid];
    web.url = str;
    [self.navigationController pushViewController:web animated:YES];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _newdiscountArr.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *freeTableCellid = @"freeTableCellID";
    FreedomTableViewCell *secondCell = [tableView dequeueReusableCellWithIdentifier:freeTableCellid];
    if (!secondCell) {
        secondCell = [[FreedomTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:freeTableCellid];
    }
    freeModel *secModel = [_newdiscountArr objectAtIndex:indexPath.row];
    [secondCell getValueWithModel:secModel];
    return secondCell;
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return SCREEN_HEIGHT/ 6 + 10;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    SlideViewController *web = [[SlideViewController alloc]init];
    freeModel *fmod = [_newdiscountArr objectAtIndex:indexPath.row];
    NSString *str = [NSString stringWithFormat:@"http://m.qyer.com/z/deal/%@/?source=app&client_id=qyer_ios&track_app_version=6.6.6&track_deviceid=301FBCE0-A789-4EAC-ADF1-95E1AACF2A70&track_user_id=6695170",fmod.cid];
    web.url = str;
    [self.navigationController pushViewController:web animated:YES];
}

-(void)pushLacal
{
    WholeFreedomViewController *local = [[WholeFreedomViewController alloc]init];
    local.left = NO;
    local.urlStr = self.urlStr;
    [self.navigationController pushViewController:local animated:YES];
}
-(void)pushFreeTravel
{
    WholeFreedomViewController *local = [[WholeFreedomViewController alloc]init];
    local.left = YES;
    local.type = 2;
    local.urlStr = self.urlStr;
    
    [self.navigationController pushViewController:local animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
